<meta charset="UTF-8">
<script>

    while (true){
        var num = prompt("输入考试科目数量");
        if (isNaN(num)){
            alert("输入无效内容");
            continue;
        }
        else if(num==0){
            alert("科目数量不能为0");
            continue;
        }
        break;
    }

    var grade = 0;
    var t = 1
    while (num!=0){
        while (true){
            var score = prompt("输入科目"+t+"考试成绩");
            if (isNaN(score)){
                alert("输入无效内容");
                continue
            }
            else if(num<0||num>100){
                alert("成绩错误");
                continue;
            }
            break;
        }
        num--;
        t++;
        grade+=parseInt(score)
    }
    document.write("总分："+grade)

</script>
